const wxaapi = require('./../../public/wxaapi.js');//api地址参数
const wxRequest = require('./../../utils/js/wxRequest.js'); //请求参数
const wxPromise = require('./../../utils/js/wxPromise.js');//promise信息
const app = getApp()

Page({
  data: {
    motto: '',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  onLoad: function () {
    getApp().fGetUserData().then(userInfo=>{
      console.log("get into index------------",userInfo);
    });
    //this.fGetPromiseAll();
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  fNavClientCase(){
  wx.navigateTo({
    url: '/page/client/pages/sharecase/sharecase',
  })
  },
  fNavCustomerCase(){
   wx.navigateTo({
     url: '/page/customer/pages/case/case',
   })
  },
  fNavTest(){
    wx.navigateTo({
      url: '/page/test/test',
    })
  },
  /**
 * 获取下拉选项项目列表
 */
  fGetDropdownProductList() {
    let _This = this;
    let unionid ="oDOgS0kCV5its31fROZtbdqcpMAE";
    let pdata = { unionId: unionid, all: 0 };//,all:0
    wxRequest(wxaapi.product.list.url, pdata).then(function (result) {
      if (result.data.code == 0) {
        let abledata = { unionId: unionid, all: 0 };//,all:0
        return wxRequest(wxaapi.product.list.url, abledata);
      } else {
        return { data: {} };
      }
    }).then(function (result) {
      console.log("get product list result all=0--------", result);
      var codearr = ["0"];
      if (result.data.code == 0) {
      } else {
        console.log(result);
      }
    });
  },
  fGetPromiseAll(){
    let unionid = "oDOgS0kCV5its31fROZtbdqcpMAE";
    let pnotdata = { unionId: unionid, all: 0 };
    let notAllData = wxRequest(wxaapi.product.list.url, pnotdata);
    let palldata = { unionId: unionid};
    let allData = wxRequest(wxaapi.product.list.url, palldata);
    wxPromise.wxPromiseAll(notAllData, allData).then(result=>{
       console.log("result data--------------",result);

    });
  }
})
